package gui.timecontrols;

import gui.TourneyManView;
import tournamentmanager.Preferences;

public class UseTimeIncrement extends TimeControls {

    public UseTimeIncrement(TourneyManView tourneyManView, Preferences model) {
        super(tourneyManView, model);
    }

    void refresh() {
        tourneyManView.chcTimeControlType.select(0);
        tourneyManView.spnTimeIncrement.setEnabled(true);
        tourneyManView.spnMovesPerSession.setEnabled(false);
    }

    public void loadFromModel() {
        refresh();
        tourneyManView.spnTimeIncrement.setSelection(model.getCurrentTournament().getTimeIncrement());
        tourneyManView.spnTimeControl.setSelection(model.getCurrentTournament().getTimeControl());
    }

    public void loadFromView() {
        refresh();
        model.getCurrentTournament().setTimeIncrement(tourneyManView.spnTimeIncrement.getSelection());
    }
}
